package com.cc8w.admin.filter;

import java.io.IOException;

import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.http.HttpFilter;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

public class LoginFilter  extends HttpFilter  {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	@Override
	protected void doFilter(HttpServletRequest req, HttpServletResponse res, FilterChain chain)
			throws IOException, ServletException {


	/*
	//用了Shiro管理认证登录 (这个就不用了) --start

		//判断session是否有值，进入后天还是跳转登录页面
		HttpSession session = req.getSession();
		String user_name = (String)session.getAttribute("username");
		if(user_name==null) {
			System.out.println("需要跳转登录...");

			String path = req.getContextPath();
			String basePath =req.getScheme() + "://" + req.getServerName() + ":" + req.getServerPort() + path + "/";
			//重定向
			res.sendRedirect(basePath+"sys/admin/login");
			return ;
			//转发
			//req.getRequestDispatcher("hello.jsp").forward(req, res);
		}

		//用了Shiro管理认证登录 (这个就不用了) --end
		*/

		
		
		super.doFilter(req, res, chain);
	}


	@Override
	public void destroy() {

	}
}
